#pragma once

#include "Defines.hpp"
#include "Widget.hpp"
#include "GridLayout.hpp"

namespace gui
{
	class Slider;

	class ScrollAreaView : public Widget 
	{
		public:
			ScrollAreaView(Rect& scroll_area);

			void SetScrollArea(Rect& scroll_area);
			const Rect& GetScrollArea() const;
		
			void SetPos(int x, int y, bool forceMove = false, bool save = true);

			void Update(float diff);
			void BasicDraw() const;
			void BetaDraw() const;
			bool AddWidget(Widget* child);
			
			void HandleHorizontalScroll(gui::OnValueChanged* v);
			void HandleVerticalScroll(gui::OnValueChanged* v);

			bool IsCollision(const Rect& second) const;

			bool HandleDragStop( Drag* drag );
			bool HandleDragMove( Drag* drag );
		private:
			void InitGraphics();
			void _HandleEvents();
			void BindWidgetToArea(Widget* widget);
			void BindAllWidgetsToArea();

			Rect m_scrollArea;
	};

	class ScrollArea : public Widget
	{
	public:
		ScrollArea();
		ScrollArea(Rect& scroll_area);

		bool AddWidget(Widget* child);

		void SetPos(int x, int y, bool forceMove = false, bool save = true);

		void SetScrollArea(Rect& scroll_area);
		const Rect& GetScrollArea() const;
		ScrollAreaView* GetView() const { return m_view; }
		bool AcceptsDrop(Drag* drag) const;
		bool RemoveWidget(Widget* widget);
		bool IsCollision(const Rect& rect) const;
	protected:
		void ReloadSettings();
		void InitGraphics();

		GridLayout* m_gridLayout;
		Slider* m_verticalSlider;
		Slider* m_horizontalSlider;
		ScrollAreaView* m_view;

		void Update(float diff);
	private:


	};

}

